
#include "sb.h"

PPM_CONSTRUCTOR_CB(constructor) {
    periphConstructor();
}

PPM_DESTRUCTOR_CB(destructor) {
	LOG("Destructor called\n");
}

PPM_REG_READ_CB(regRd32) {
	TimingParameter **tp = tl-> timingparameters; 
	if(paramPosition <= tl-> count) {
		if(paramPosition != tl-> count) {
			ppmWriteNet(handles.timep, tp[paramPosition]-> time);
			ppmWriteNet(handles.valuep, 1);
			LOG ("Wrote parameter on net: %d \n", tp[paramPosition]-> time);	
		}
		else {
			ppmWriteNet(handles.valuep, 0);
		}
		*(Uns32*)user = tp[paramPosition - 1]-> sensor1;
		LOG ("Wrote parameters in register: 0x%x  %u\n", *(Uns32*)user, *(Uns32*)user);
		paramPosition++;
	}
    return *(Uns32*)user;
}
